package com.cos.shop.dao.impl;

import com.cos.shop.dao.TypeDao;
import com.cos.shop.entity.Type;
import com.cos.shop.util.DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author: COS
 * @time: 2023/5/11 10:12
 * @description:
 */
public class TypeDaoImpl implements TypeDao {
    private QueryRunner qr = new QueryRunner(DBUtils.getDataSource());
    @Override
    public List<Type> getAll() throws SQLException {
        String sql  = "select t_id 'tid' ,t_name 'tname',t_info 'tinfo' from type";
        return qr.query(sql,new BeanListHandler<>(Type.class));
    }
}
